import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [{
  path: '/',
  name: 'Home',
  component: () => import(/* webpackChunkName: "home" */ '../views/home/Home.vue')
}, {
  path: '/cartList',
  name: 'CartList',
  component: () => import(/* webpackChunkName: "cartList" */ '../views/cartList/CartList.vue')
}, {
  path: '/shop/:id',
  name: 'Shop',
  component: () => import(/* webpackChunkName: "shop" */ '../views/shop/Shop.vue')
}, {
  path: '/register',
  name: 'Register',
  component: () => import(/* webpackChunkName: "register" */ '../views/register/Register.vue'),
  // 移除登录检查
  beforeEnter(to, from, next) {
    next();
  }
}, {
  path: '/login',
  name: 'Login',
  component: () => import(/* webpackChunkName: "login" */ '../views/login/Login.vue'),
  // 移除登录检查
  beforeEnter(to, from, next) {
    next();
  }
},
{
  path: '/mine',
  name: 'Mine',
  component: () => import(/* webpackChunkName: "mine" */ '../views/Mine.vue')
},
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   
  // }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

// 移除全局路由守卫，允许直接访问所有页面
router.beforeEach((to, from, next) => {
  next();
})

export default router
